﻿namespace MyWebLog.Models.UI
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// A message to be displayed to the user
    /// </summary>
    public class UserMessage
    {
        /// <summary>
        /// A list of message types
        /// </summary>
        public enum MessageType
        {
            Error, Warning, Message
        };

        /// <summary>
        /// The type of the message
        /// </summary>
        public MessageType Type { get; set; }

        /// <summary>
        /// The message to be displayed (can contain HTML)
        /// </summary>
        public HtmlString Message { get; set; }

        /// <summary>
        /// A more descriptive part of the message (can contain HTML)
        /// </summary>
        public HtmlString Description { get; set; }

        /// <summary>
        /// The unencoded message text (will be escaped)
        /// </summary>
        public string MessageText
        {
            set
            {
                Message = new HtmlString(HttpUtility.HtmlEncode(value));
            }
        }

        /// <summary>
        /// The unencoded message text (will be escaped)
        /// </summary>
        public string DescriptionText
        {
            set
            {
                Description = new HtmlString(HttpUtility.HtmlEncode(value));
            }
        }
    }
}